﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package reprise.utils {
    import flash.display.*;
    import flash.geom.*;
    import reprise.data.*;

    public class Gradient {

        protected var m_colors:Array;
        protected var m_rotation:Number = 90
        protected var m_origin:Point;
        protected var m_height:Number;
        protected var m_spreadMethod:String;
        protected var m_interpolationMethod:String;
        protected var m_focalPointRatio:Number;
        protected var m_matrix:Matrix;
        protected var m_ratios:Array;
        protected var m_alphas:Array;
        protected var m_fillType:String;
        protected var m_width:Number;

        public static const INTERPOLATION_LINEAR:String = "linearRGB";
        public static const LINEAR:String = "linear";
        public static const SPREAD_REPEAT:String = "repeat";
        public static const SPREAD_REFLECT:String = "reflect";
        public static const INTERPOLATION_RGB:String = "RGB";
        public static const SPREAD_PAD:String = "pad";
        public static const RADIAL:String = "radial";

        public function Gradient(_arg1:String=null, _arg2:Array=null, _arg3:Array=null, _arg4:Array=null, _arg5:Matrix=null, _arg6:String=null, _arg7:String=null, _arg8:Number=1){
            m_fillType = ((_arg1 == null)) ? LINEAR : _arg1;
            m_colors = ((_arg2 == null)) ? [0, 0xFFFFFF] : _arg2;
            m_alphas = ((_arg3 == null)) ? [] : _arg3;
            m_ratios = ((_arg4 == null)) ? [] : _arg4;
            m_matrix = _arg5;
            m_spreadMethod = _arg6;
            m_interpolationMethod = _arg7;
            m_focalPointRatio = _arg8;
            m_origin = new Point(0, 0);
        }
        public function setRotation(_arg1:Number):void{
            m_rotation = _arg1;
        }
        public function setWidth(_arg1:Number):void{
            m_width = _arg1;
        }
        public function focalPointRatio():Number{
            return (m_focalPointRatio);
        }
        public function beginGradientFill(_arg1:Graphics, _arg2:Number=0, _arg3:Number=0, _arg4:Number=0):void{
            if ((((m_alphas == null)) || (!((m_alphas.length == m_colors.length))))){
                initDefaultAlphas();
            };
            if ((((m_ratios == null)) || (!((m_ratios.length == m_colors.length))))){
                initDefaultRatios();
            };
            var _local5:Matrix = m_matrix;
            if (m_matrix == null){
                _local5 = new Matrix();
                _local5.createGradientBox(_arg2, _arg3, ((m_rotation / 180) * Math.PI), m_origin.x, m_origin.y);
            };
            _arg1.beginGradientFill(m_fillType, m_colors, m_alphas, m_ratios, _local5, m_spreadMethod, m_interpolationMethod, m_focalPointRatio);
        }
        public function interpolationMethod():String{
            return (m_interpolationMethod);
        }
        public function setOrigin(_arg1:Point):void{
            m_origin = _arg1;
        }
        public function setHeight(_arg1:Number):void{
            m_height = _arg1;
        }
        public function height():Number{
            return (m_height);
        }
        public function spreadMethod():String{
            return (m_spreadMethod);
        }
        public function origin():Point{
            return (m_origin);
        }
        public function setSpreadMethod(_arg1:String):void{
            m_spreadMethod = _arg1;
        }
        public function equals(_arg1:Gradient):Boolean{
            return ((((((((((((((((((((((fillType() == _arg1.fillType())) && (ArrayUtil.compareArrays(colors(), _arg1.colors())))) && (ArrayUtil.compareArrays(alphas(), _arg1.alphas())))) && (ArrayUtil.compareArrays(ratios(), _arg1.ratios())))) && ((spreadMethod() == _arg1.spreadMethod())))) && ((interpolationMethod() == _arg1.interpolationMethod())))) && ((focalPointRatio() == _arg1.focalPointRatio())))) && ((width() == _arg1.width())))) && ((height() == _arg1.height())))) && ((rotation() == _arg1.rotation())))) && ((((matrix() == _arg1.matrix())) || ((matrix().toString() == _arg1.matrix().toString()))))));
        }
        protected function initDefaultRatios():void{
            m_ratios = [];
            var _local1:int = m_colors.length;
            var _local2:Number = (0xFF / (_local1 - 1));
            var _local3:Number = 0;
            while (_local1--) {
                m_ratios.push(_local3);
                _local3 = (_local3 + _local2);
            };
        }
        public function matrix():Matrix{
            return (m_matrix);
        }
        public function setMatrix(_arg1:Matrix):void{
            m_matrix = _arg1;
        }
        public function ratios():Array{
            return (m_ratios);
        }
        public function setRatios(_arg1:Array):void{
            m_ratios = _arg1;
        }
        public function lineGradientStyle(_arg1:Graphics, _arg2:Number=0, _arg3:Number=0, _arg4:Number=0):void{
            if ((((m_alphas == null)) || (!((m_alphas.length == m_colors.length))))){
                initDefaultAlphas();
            };
            if ((((m_ratios == null)) || (!((m_ratios.length == m_colors.length))))){
                initDefaultRatios();
            };
            var _local5:Matrix = m_matrix;
            if (m_matrix == null){
                _local5 = new Matrix();
                _local5.createGradientBox(_arg2, _arg3, ((m_rotation / 180) * Math.PI), m_origin.x, m_origin.y);
            };
            _arg1.lineGradientStyle(m_fillType, m_colors, m_alphas, m_ratios, _local5, m_spreadMethod, m_interpolationMethod, m_focalPointRatio);
        }
        public function setAlphas(_arg1:Array):void{
            m_alphas = _arg1;
        }
        public function alphas():Array{
            return (m_alphas);
        }
        public function fillType():String{
            return (m_fillType);
        }
        public function setFocalPointRatio(_arg1:Number):void{
            m_focalPointRatio = _arg1;
        }
        public function setFillType(_arg1:String):void{
            m_fillType = _arg1;
        }
        public function setInterpolationMethod(_arg1:String):void{
            m_interpolationMethod = _arg1;
        }
        public function clone():Gradient{
            var _local1:Gradient = new Gradient(m_fillType);
            _local1.setColors(m_colors.concat());
            _local1.setAlphas(m_alphas.concat());
            _local1.setRatios(m_ratios.concat());
            _local1.setSpreadMethod(m_spreadMethod);
            _local1.setInterpolationMethod(m_interpolationMethod);
            _local1.setFocalPointRatio(m_focalPointRatio);
            _local1.setWidth(m_width);
            _local1.setHeight(m_height);
            _local1.setRotation(m_rotation);
            _local1.setMatrix(m_matrix.clone());
            return (_local1);
        }
        public function setColors(_arg1:Array):void{
            var _local2:Object;
            m_colors = [];
            m_alphas = [];
            var _local3:int;
            while (_local3 < _arg1.length) {
                _local2 = _arg1[_local3];
                if ((_local2 is AdvancedColor)){
                    m_colors.push(_local2.rgb());
                    m_alphas.push(_local2.opacity());
                } else {
                    m_colors.push(_local2);
                    m_alphas.push(1);
                };
                _local3++;
            };
        }
        public function width():Number{
            return (m_width);
        }
        public function colors():Array{
            return (m_colors);
        }
        public function rotation():Number{
            return (m_rotation);
        }
        protected function initDefaultAlphas():void{
            m_alphas = [];
            var _local1:int = m_colors.length;
            while (_local1--) {
                m_alphas.push(1);
            };
        }

    }
}//package reprise.utils 
